//部分控制器
var app = angular.module('myApp.controllers');

//example首页
app.controller('couponIndex', ["$scope", "utilService", "$rootScope", function ($scope, utilService, $rootScope) {
    /*模拟数据*/
    $scope.couponList = [{id:1},{id:2},{id:3}];
    /*点击跳转详情*/
    $scope.toDetail = function (item) {
      utilService.$state.go('coupon.detail', {id: item.id});
    }
    $scope.$on('$ionicView.beforeEnter', function () {
        //页面刚加载
        utilService.$ionicLoading.show(HX_CONFIG.loadingBase);
    }, false);
    $scope.$on('$ionicView.afterEnter', function () {
        utilService.$rootScope.rootData.title = '我的卡券';
        //页面加载完成
        utilService.$ionicLoading.hide();
    }, false);
    $rootScope.$on('$ionicView.beforeLeave', function (e, ion) {
        //页面离开之前
        //alertPopup && alertPopup.close();

    }, false);

}]);
app.controller('couponDetail', ["$scope", "utilService", "$rootScope", function ($scope, utilService, $rootScope) {
  /*显示状态*/
  $scope.couponState = 1;
  /*点击切换*/
  $scope.toggleShow = function () {
    if($scope.couponState == 1){
      $scope.couponState = 2;
    }else{
      $scope.couponState = 1;
    }
  }

  $scope.$on('$ionicView.beforeEnter', function () {
    //页面刚加载
    utilService.$ionicLoading.show(HX_CONFIG.loadingBase);
  }, false);
  $scope.$on('$ionicView.afterEnter', function () {
    utilService.$rootScope.rootData.title = '卡券详情';
    //页面加载完成
    utilService.$ionicLoading.hide();
  }, false);
  $rootScope.$on('$ionicView.beforeLeave', function (e, ion) {
    //页面离开之前
    //alertPopup && alertPopup.close();

  }, false);

}]);